﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BuilderPattern.GameCharacter
{
    /// <summary>
    /// 角色建造者：抽象建造者
    /// </summary>
    abstract class ActorBuilder
    {
        protected readonly Actor actor = new Actor();

        public abstract void BuildType();
        public abstract void BuildSex();
        public abstract void BuildFace();
        public abstract void BuildCostume();
        public abstract void BuildHairstyle();

        //钩子方法，需要使用 virtual 关键字
        public virtual bool IsBareheaded()
        {
            return false;
        }

        //工厂方法，返回一个完整的游戏角色对象
        public Actor CreateActor()
        {
            return actor;
        }
    }

    /*
     // 简化方式1：省略 Director 
    abstract class ActorBuilder
    {
        // 设置对象静态 & 只读并且实例化
        protected static readonly Actor actor = new Actor();

        public abstract void BuildType();
        public abstract void BuildSex();
        public abstract void BuildFace();
        public abstract void BuildCostume();
        public abstract void BuildHairstyle();

        // 工厂方法，返回一个完整的游戏角色对象
        public Actor CreateActor(ActorBuilder ab)
        {
            ab.BuildType();
            ab.BuildSex();
            ab.BuildFace();
            ab.BuildCostume();
            ab.BuildHairstyle();
            return actor;
        }
    }
    */

    /*
     // 简化方式2 ：去除 CreateActor(ActorBuilder ab) 方法的参数 ActorBuilder，直接在该方法中调用 this.BuildXXX() 方法
    abstract class ActorBuilder
    {
        // 设置对象静态 & 只读并且实例化
        protected static readonly Actor actor = new Actor();

        public abstract void BuildType();
        public abstract void BuildSex();
        public abstract void BuildFace();
        public abstract void BuildCostume();
        public abstract void BuildHairstyle();

        // 工厂方法，返回一个完整的游戏角色对象
        public Actor CreateActor()
        {
            this.BuildType();
            this.BuildSex();
            this.BuildFace();
            this.BuildCostume();
            this.BuildHairstyle();
            return actor;
        }
    }
    */

}
